package com.task.manager.mapper;

import com.task.manager.domain.ProjectTask;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ProjectTaskMapper {
	@Delete({ "delete from t_project_task", "where ID = #{id,jdbcType=INTEGER}" })
	int deleteByPrimaryKey(Integer id);

	@Insert({ "insert into t_project_task (ID, PROJECT_CODE, ", "PROJECT_NAME, TASK_CODE, ", "TASK_NAME, CREATE_TIME)", "values (#{id,jdbcType=INTEGER}, #{projectCode,jdbcType=VARCHAR}, ",
			"#{projectName,jdbcType=VARCHAR}, #{taskCode,jdbcType=VARCHAR}, ", "#{taskName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})" })
	int insert(ProjectTask record);

	@InsertProvider(type = ProjectTaskSqlProvider.class, method = "insertSelective")
	int insertSelective(ProjectTask record);

	@Select({ "select", "ID, PROJECT_CODE, PROJECT_NAME, TASK_CODE, TASK_NAME, CREATE_TIME", "from t_project_task", "where ID = #{id,jdbcType=INTEGER}" })
	@Results({ @Result(column = "ID", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "PROJECT_CODE", property = "projectCode", jdbcType = JdbcType.VARCHAR),
			@Result(column = "PROJECT_NAME", property = "projectName", jdbcType = JdbcType.VARCHAR), @Result(column = "TASK_CODE", property = "taskCode", jdbcType = JdbcType.VARCHAR),
			@Result(column = "TASK_NAME", property = "taskName", jdbcType = JdbcType.VARCHAR), @Result(column = "CREATE_TIME", property = "createTime", jdbcType = JdbcType.TIMESTAMP) })
	ProjectTask selectByPrimaryKey(Integer id);

	@UpdateProvider(type = ProjectTaskSqlProvider.class, method = "updateByPrimaryKeySelective")
	int updateByPrimaryKeySelective(ProjectTask record);

	@Update({ "update t_project_task", "set PROJECT_CODE = #{projectCode,jdbcType=VARCHAR},", "PROJECT_NAME = #{projectName,jdbcType=VARCHAR},", "TASK_CODE = #{taskCode,jdbcType=VARCHAR},",
			"TASK_NAME = #{taskName,jdbcType=VARCHAR},", "CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}", "where ID = #{id,jdbcType=INTEGER}" })
	int updateByPrimaryKey(ProjectTask record);
}